package com.xuzao.developer.service.impl;

import com.github.pagehelper.PageInfo;
import com.xuzao.developer.base.model.GridFieldSys;
import com.xuzao.developer.dao.GridFieldSysDao;
import com.xuzao.developer.dto.GridFieldSysDTO;

import javax.annotation.Resource;

import com.xuzao.developer.tools.entity.Pager;
import com.xuzao.developer.vo.BaseResultVo;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import com.xuzao.developer.service.GridFieldSysService;


/**
 * @description 
 * @author xuzao
 * @date 2019-09-03 17:12:57
 **/
@Service("gridFieldSysService")
public class GridFieldSysServiceImpl implements GridFieldSysService {

	@Resource
	private GridFieldSysDao gridFieldSysDao;

	@Override
	public PageInfo<GridFieldSys> list(GridFieldSysDTO dto, Pager pager) {
		return gridFieldSysDao.list(dto, pager);
	}

	@Override
	public BaseResultVo insert(GridFieldSysDTO dto) {
		GridFieldSys gridFieldSys = new GridFieldSys();
		//TODO 赋值
		if (dto.getGridId()!=null){
			gridFieldSys.setGridId(dto.getGridId().toString());
		}
		BeanUtils.copyProperties(dto,gridFieldSys);
		Integer count = gridFieldSysDao.insertSelective(gridFieldSys);
		if (count > 0) {
			return BaseResultVo.success();
		}
		return BaseResultVo.error();

	}

	@Override
	public BaseResultVo update(GridFieldSysDTO dto) {
		GridFieldSys gridFieldSys = new GridFieldSys();
		//TODO 赋值
		BeanUtils.copyProperties(dto,gridFieldSys);
		Integer count = gridFieldSysDao.updateSelectiveById(gridFieldSys);
		if (count > 0) {
			return BaseResultVo.success();
		}
		return BaseResultVo.error();
	}

	@Override
	public BaseResultVo get(GridFieldSysDTO dto) {
		GridFieldSys gridFieldSys = new GridFieldSys();
		return BaseResultVo.success(gridFieldSysDao.selectById(gridFieldSys.getId()));
	}

	@Override
	public void del(Long id) {
		gridFieldSysDao.deleteById(id);
	}
}